#include "logcoordstransformer.h"
#include <math.h>

QPointF LogCoordsTransformer::transform(QPointF coords)
{
    QPointF result;
    if(coords.x() == 0)
        result.setX(0);
    else if(coords.x() < 0)
        result.setX(-transformCoord(-coords.x()));
    else
        result.setX(transformCoord(coords.x()));

    if(coords.y() == 0)
        result.setY(0);
    else if(coords.y() < 0)
        result.setY(-transformCoord(-coords.y()));
    else
        result.setY(transformCoord(coords.y()));

    return result;
}

double LogCoordsTransformer::transformCoord(double x)
{
    double result = log(x)/log(10.0);
    if(result < 0)
    {
        result = pow(2.0, result);
    }
    else
    {
        result = result + 1;
    }
    return result;
}

